package com.ruoyi.rocky.controller;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.rocky.domain.PcFeedback;
import com.ruoyi.rocky.service.PcFeedbackService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

@Slf4j
@Validated
@RestController
@RequestMapping("/pcFeedback")
@AllArgsConstructor
@Api(tags = "反馈管理")
public class PcFeedbackController extends BaseController {

    @Autowired
    private PcFeedbackService pcFeedbackService;

    /**
     * 查询反馈管理列表
     */
    @ApiOperation(value = "查询反馈管理列表")
    @GetMapping("/list")
    public TableDataInfo list(PcFeedback pcFeedback) {
        startPage();
        List<PcFeedback> list = pcFeedbackService.selectPcFeedbackList(pcFeedback);
        return getDataTable(list);
    }

//    /**
//     * 导出反馈管理列表
//     */
//    @ApiOperation(value = "导出反馈管理列表")
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, PcFeedback pcFeedback) {
//        List<PcFeedback> list = pcFeedbackService.selectPcFeedbackList(pcFeedback);
//        ExcelUtil<PcFeedback> util = new ExcelUtil<PcFeedback>(PcFeedback.class);
//        util.exportExcel(response, list, "反馈管理数据");
//    }

    /**
     * 根据反馈id获取反馈管理详细信息
     */
    @ApiOperation(value = "根据反馈id获取反馈管理详细信息")
    @GetMapping(value = "/{feedbackId}")
    public AjaxResult getInfo(@PathVariable("feedbackId") Long feedbackId) {
        return success(pcFeedbackService.selectPcFeedbackByFeedbackId(feedbackId));
    }

    /**
     * 新增反馈管理
     */
    @ApiOperation(value = "新增反馈管理")
    @PostMapping
    public R add(@RequestBody PcFeedback pcFeedback) {
        return R.ok(pcFeedbackService.insertPcFeedback(pcFeedback));
    }

//    /**
//     * 修改反馈管理
//     */
//    @PutMapping
//    public AjaxResult edit(@RequestBody PcFeedback pcFeedback)
//    {
//        return toAjax(pcFeedbackService.updatePcFeedback(pcFeedback));
//    }

    /**
     * 删除反馈管理
     */
    @ApiOperation(value = "删除反馈管理")
    @DeleteMapping("/{feedbackIds}")
    public R remove(@PathVariable Long[] feedbackIds) {
        return R.ok(pcFeedbackService.deletePcFeedbackByFeedbackIds(feedbackIds));
    }
}
